package com.hx.test.security.config.security;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

/**
 * http security override
 * 添加注解Configuration才生效 (查看源码时实际上new的像类,有待验证)
 *
 * @author 华云龙
 * @date 2019-5-16
 */
@Configuration
public class HttpSecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .antMatchers("/no").access("hasRole('ADMIN')")
                .anyRequest().authenticated()
                .and().formLogin()
                .and().httpBasic();

    }
}
